import java.util.ArrayList;
import java.util.Scanner;

public class StudentManager {
    static class Student {
        String name;
        String id;
        String course;
        double score;
    }

    static ArrayList<Student> students = new ArrayList<>();

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (true) {
            System.out.println("\n学生成绩管理系统");
            System.out.println("1. 记录成绩\n2. 查询成绩\n3. 退出");
            System.out.print("请输入选项：");
            
            int choice = scanner.nextInt();
            scanner.nextLine(); // 清除换行符

            switch (choice) {
                case 1 -> addScore(scanner);
                case 2 -> queryScore(scanner);
                case 3 -> { return; }
                default -> System.out.println("无效选项！");
            }
        }
    }

    static void addScore(Scanner scanner) {
        Student s = new Student();
        System.out.print("输入姓名：");
        s.name = scanner.nextLine();
        System.out.print("输入学号：");
        s.id = scanner.nextLine();
        System.out.print("输入课程：");
        s.course = scanner.nextLine();
        System.out.print("输入成绩：");
        s.score = scanner.nextDouble();
        students.add(s);
        System.out.println("记录成功！");
    }

    static void queryScore(Scanner scanner) {
        System.out.print("输入学号查询：");
        String id = scanner.nextLine();
        for (Student s : students) {
            if (s.id.equals(id)) {
                System.out.printf("姓名：%s 课程：%s 成绩：%.1f\n", 
                    s.name, s.course, s.score);
                return;
            }
        }
        System.out.println("未找到记录！");
    }
}